#include "../glob.h"

void func(int param)
{
	DEBUG("param.........%d",param);
	exit(0);
	return ;
}

int catch_sig_segment()
{
	int handle = SIGSEGV;
	struct sigaction sig_act;
	
	DEBUG("handle=%d",handle);
	
	sig_act.sa_handler = func;
	sigemptyset(&sig_act.sa_mask);
	sig_act.sa_flags = 0;
	sigaction(handle,&sig_act,NULL);
	
	return 0;
}

int catch_sig_segment_test()
{
	char *buff = NULL;
	
	memcpy(buff,"123",9);

	return 0;
}

int main(int argc, char* argv[])
{
	int handle = SIGILL;
	int count = 0;
	struct sigaction sig_act;
	
	DEBUG("handle=%d",handle);	
	
#if 0	
	signal(SIGKILL,func);
#else	
	sig_act.sa_handler = func;
	sigemptyset(&sig_act.sa_mask);
	sig_act.sa_flags = 0;
	
	sigaction(handle, &sig_act, NULL);
#endif	
	
	catch_sig_segment();
	//catch_sig_segment_test();
	
	while(1 && count<20)
	{
		DEBUG("count.=%d",count);	
		sleep(2);
		count++;
	}
	
	DEBUG("END!!!");

	return 0;
}